'use strict';

const db = uniCloud.database();
const add_db = db.collection('comments');
exports.main = async (event, context) => {
	let myDate = new Date();
	const rq = myDate.getFullYear()+'-'+(myDate.getMonth()+1)+'-'+myDate.getDate()+' '+(myDate.getHours())+':'+(myDate.getMinutes())+':'+(myDate.getSeconds()+1);
	//console.log(rq);
	let res = await add_db.add({
		user:event.user,
		comment:event.comment,
		create_time: rq,
	})
	//返回数据给客户端
	return res;
};
